<script type="text/javascript" language="javascript">
    (function($) {
        /*whatever jQuery stuff*/
        $(function(){				
            $("#Form").validate({
                rules: {
                    group_name: "required"
                },
                showErrors: function(errorMap, errorList){
                    var messages='';
                    for (var i = 0; i < errorList.length; i++) {					
                        messages += '- '+errorList[i].message+'\n';
                    }
                    if(messages) alert("<?php echo lang('requirement');?>: \n"+"¯¯¯¯¯¯¯¯¯¯ \n"+ messages);
                    //this.defaultShowErrors();
                } ,
                submitHandler: function(e){
					$('.ajax-loading',e).css('visibility','visible');
					form.submit();
                },
                onfocusout: false,
                onkeyup: false,
				onclick: false,						
                messages: {
                    group_name: "<?php echo lang('group_name');?>"
                }
            });			
        });
    })(jQuery);
</script>
<div class="wrap">
 	<div id="icon-index" class="icon32"><br /></div><h2><?php echo ucwords(str_replace('_',' ',$this->uri->segment(1)));?> &raquo; <?php echo ucwords(str_replace('_',' ',$this->uri->segment(2)));?> &raquo; <?php echo lang($this->uri->segment(3));?></h2>
</div>
<div id="wpbody-content">
    <div class="metabox-holder" id="dashboard-widgets">
		<div class="tablenav top">
			<div class="alignleft"><input type="button" value="<?php echo lang('button_back');?>" class="button-primary" onclick="javascript:history.go(-1);"/></div>
		</div>	
            <div class="inside">			
				<form id="Form" method="post" action="" name="Form">
					<table border="0" cellspacing="0" cellpadding="0" class="form-table">
						<tbody>
						<tr>
							<th scope="row"><?php echo lang('group_name');?></th>
							<td><input type="text" name="group_name" id="group_name" class="medium-text" value="<?php echo $dataResult->group_name;?>"/></td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('group_permission');?></th>
							<td>
								<div id="permission_list">
								<?php
								$main_menu = array();
								foreach($dataPermission as $key => $value):
									if(!in_array($value->mainmenu_id,$main_menu)):
										$main_menu[] = $value->mainmenu_id;
										if($key==0):
											echo "<ul>";
								?>
											<li class="first"><input type="checkbox" name="mainmenu_id[]" class="parent-<?php echo $value->mainmenu_id;?>" value="<?php echo $value->mainmenu_id;?>" <?php echo (!empty($generate_menu[$value->mainmenu_id]) ? 'checked="checked"':'');?>><?php echo $value->main_name;?></li>
								<?php
										else:
											echo "</ul><ul>";
								?>
											<li class="first"><input type="checkbox" name="mainmenu_id[]" class="parent-<?php echo $value->mainmenu_id;?>" value="<?php echo $value->mainmenu_id;?>" <?php echo (!empty($generate_menu[$value->mainmenu_id]) ? 'checked="checked"':'');?>><?php echo $value->main_name;?></li>
								<?php
										endif;
									endif;
								?>
										<li><input type="checkbox" name="submenu_id[<?php echo $value->mainmenu_id;?>][]" class="child-<?php echo $value->mainmenu_id;?>" value="<?php echo $value->submenu_id;?>" <?php echo (!empty($generate_menu[$value->mainmenu_id]['submenu'][$value->submenu_id]) ? 'checked="checked"':'');?>><?php echo $value->sub_name;?></li>
								<?php 
								endforeach;
								echo "</ul>";
								?>
								</div>
							</td>
						</tr>
						<tr>
							<th scope="row">&nbsp;</th>
							<td><p class="submit"><input type="submit" value="<?php echo lang('button_edit');?>" class="button-primary" />&nbsp;<img alt="" class="ajax-loading" src="<?php echo css_asset_url('images/wpspin_light.gif'); ?>" /></p></td>
						</tr>								
						</tbody>
					</table>
					<div class="tablenav bottom"></div>
				</form>
            </div><!-- wpbody inside -->
    </div><!-- wpcontent -->
</div><!-- wpbody-content -->